home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Sample Code / Snippets / Development Tools & Languages / DTSCPlusLibrary / Sources / ProcessTest.cp < prev    next >
Encoding:
Text File  |  1993-01-14  |  2.1 KB  |  64 lines  |  [TEXT/MPS ]

  1. /* _________________________________________________________________________________________________________ //
  2.   Copyright © 1992 Apple Computer, Inc. All rights reserved.
  3.   Macintosh Developer Technical Support.C++ Macintosh Toolbox Framework.
  4.   Originator: Kent Sandvik
  5.   Date: Wednesday, June 10, 1992 22:37:30
  6.   Revision comments are at the end of this file.
  7.   ---
  8.   TProcess is a Process Manager class.
  9.   ProcessTest.cp contains the testing code for testing TProcess.
  10.   _________________________________________________________________________________________________________ */
  11.  
  12.  
  13. // Include files
  14. #ifndef _PROCESS_
  15. #include "Process.h"
  16. #endif
  17.  
  18.  
  19. // This test program will first create a TProcess object that will probe the current process
  20. // itself. The second test will iterate through processes in the list and print out information.
  21. // The final test will find the Finder Process ('MACS').
  22.  
  23.  
  24. void main(void)
  25. {
  26.     cout << "Start TProcess testing…\n";
  27.  
  28.     // create default TProcess
  29.     TProcess myProcess;
  30.  
  31.     cout << "First test, the current process\n";
  32.     cout << "We have just now " << myProcess.GetNumProcesses() << " processes running.\n";
  33.     cout << "This process has " << myProcess.GetFreeMem() << " memory free.\n";
  34.  
  35.     cout << "\nSecond test, iteration of processes…\n";
  36.  
  37.     for (TProcess procs; !procs.Last(); procs.Next())
  38.     {
  39.         ProcessSerialNumber thePSN = procs.GetProcessID();
  40.         cout << "High Process ID = " << thePSN.highLongOfPSN << "\n";
  41.         cout << "Low Process ID = " << thePSN.lowLongOfPSN << "\n";
  42.  
  43.         cout << "Process size (bytes) = " << procs.GetProcessSize() << "\n";
  44.         cout << "Free memory (bytes) = " << procs.GetFreeMem() << "\n";
  45.         cout << "Launch date (seconds) = " << procs.GetLaunchDate() << "\n";
  46.     }
  47.  
  48.     cout << "\nFinal test, try to find a process with signature 'MACS' (Finder)\n ";
  49.     TProcess findProc;
  50.     if (findProc.FindProcess('MACS'))
  51.         cout << " Finder Process found!\n";
  52.  
  53.     cout << "\nEnd TProcess testing!\n";
  54. }
  55.  
  56.  
  57. // _________________________________________________________________________________________________________ //
  58.  
  59. /*    Change History (most recent last):
  60.   No        Init.    Date        Comment
  61.   1            khs        6/10/92        New file
  62.   2            khs        7/6/92        First decent working class
  63. */
  64.